#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
    m_pGetCamera = nullptr;
    m_timer = nullptr;
}

Dialog::~Dialog()
{
    delete ui;
}


void Dialog::on_pushButton_openCamera_clicked()
{
    if(nullptr == m_pGetCamera){
        m_pGetCamera = new GetCameraFrame_Thread(this);
    }
}

void Dialog::on_pushButton_GetVideo_clicked()
{
    if(nullptr == m_timer){
        m_timer = new QTimer(this);
        connect(m_timer, &QTimer::timeout, [=](){
            if(nullptr != m_pGetCamera){
                QImage img;
                m_pGetCamera->GetVideoFrameQImage(img);
                ui->widget->setImage(img);
            }
        });
        m_timer->start(100);
    }
}
